package cn.chenchendemospringboot.stock_demo.schedule;

import cn.chenchendemospringboot.stock_demo.service.Impl.KafkaEvenProcessServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
@EnableScheduling
@Slf4j
public class ProcessSchedule {

    private final KafkaEvenProcessServiceImpl kafkaEvenProcessService;;

    // 通过构造器注入 KafkaEventPublishServiceImpl
    public ProcessSchedule(KafkaEvenProcessServiceImpl kafkaEvenProcessService) {
        this.kafkaEvenProcessService = kafkaEvenProcessService;
    }
    @Scheduled(fixedRate = 5000)
    public void publish() {
        log.info("EventPublishSchedule execute.");
        kafkaEvenProcessService.process();
    }
}
